home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / bbs / wwbbs31_source.lha / WWBBS / RxSrc / filebase_tag.c < prev    next >
C/C++ Source or Header  |  1995-03-30  |  3KB  |  140 lines

  1. #include <exec/types.h>
  2. #include <exec/exec.h>
  3. #include <libraries/wwbbs.h>
  4. #include <ctype.h>
  5. #include <math.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9.  
  10. #include <proto/dos.h>
  11. #include <proto/exec.h>
  12. #include <proto/rexxsyslib.h>
  13. #include <proto/wwbbs.h>
  14.  
  15. #include "rx.h"
  16.  
  17. #include "filebase.h"
  18.  
  19. void ClearFileTagList(BYTE *id)
  20.     {
  21.         if(Ask("Clear file tag list",FALSE))
  22.             {
  23.                 struct Node *node;
  24.                 while(node=RemHead(file_taglist))
  25.                     FreeVec(node);
  26.                 printf("~s\nFile tag list cleared.\n");
  27.             }
  28.     }
  29.  
  30. void EditFileTagList(BYTE *id)
  31.     {
  32.         BOOL kg=TRUE;
  33.         int count;
  34.         while(!panic && kg)
  35.             {
  36.                 count=0;
  37.                 {
  38.                     struct Node *node;
  39.                     for(node=file_taglist->lh_Head;node->ln_Succ;node=node->ln_Succ)
  40.                         count++;
  41.                 }
  42.                 if(count)
  43.                     {
  44.                         {
  45.                             int width,i=0;
  46.                             width=((int) (log10((double) count)+1)>3) ? (int) (log10((double) count)+1) : 3;
  47.                             printf("\n~h");
  48.                             printf("%*sNum File                             Size      \n",width-3,"");
  49.                             printf("~o");
  50.                             {
  51.                                 struct FileTagNode *node;
  52.                                 for(node=(struct FileTagNode *) file_taglist->lh_Head;node->ftn_Node.ln_Succ;node=(struct FileTagNode *) node->ftn_Node.ln_Succ)
  53.                                     {
  54.                                         if(WaitForChar(Input(),0))
  55.                                             {
  56.                                                 getchar();
  57.                                                 break;
  58.                                             }
  59.                                         printf("%*d %-32s %ld\n",width,i+1,FilePart(node->ftn_Name),node->ftn_Size);
  60.                                         i++;
  61.                                     }
  62.                             }
  63.                         }
  64.                         {
  65.                             char buff[11];
  66.                             printf("~p\nEdit File Tag List: ");
  67.                             if(GetLine(buff,10,GLFLG_NoChars))
  68.                                 {
  69.                                     struct FileTagNode *wn,*nn;
  70.                                     int i=0;
  71.                                     wn=(struct FileTagNode *) file_taglist->lh_Head;
  72.                                     while(nn=(struct FileTagNode *) wn->ftn_Node.ln_Succ)
  73.                                         {
  74.                                             if(IsRange(buff,i+1))
  75.                                                 {
  76.                                                     Remove((struct Node *) wn);
  77.                                                     FreeVec(wn);
  78.                                                 }
  79.                                             wn=nn;
  80.                                             i++;
  81.                                         }
  82.                                 }
  83.                             else
  84.                                 kg=FALSE;
  85.                         }
  86.                     }
  87.                 else
  88.                     {
  89.                         printf("~s\nFile tag list is empty.\n");
  90.                         kg=FALSE;
  91.                     }
  92.             }
  93.     }
  94.  
  95. void TagFile(BYTE *id)
  96.     {
  97.         if(strlen(file_area))
  98.             {
  99.                 if(file_current)
  100.                     {
  101.                         BYTE file[256];
  102.                         strcpy(file,"");
  103.                         if(GetConfigTags(CFGTAG_Path,file_path,CFGTAG_Name,file_area,FBTAG_Directory,file,TAG_END))
  104.                             {
  105.                                 APTR group;
  106.                                 if(group=OpenFileGroup(file_path,file_area,SHARED_LOCK))
  107.                                     {
  108.                                         BYTE *name=NULL;
  109.                                         ULONG size=0;
  110.                                         if(GetFileTags(group,FILTAG_ID,file_current,FILTAG_Name,&name,FILTAG_Size,&size,TAG_END))
  111.                                             {
  112.                                                 AddPart(file,name,255);
  113.                                                 if(FindName(file_taglist,file))
  114.                                                     {
  115.                                                         if(DeleteFileTag(file_taglist,file))
  116.                                                             printf("~s\nRemoved `%s' from file tag list.\n",name);
  117.                                                         else
  118.                                                             printf("~s\nUnable to remove `%s' from file tag list.\n",name);
  119.                                                     }
  120.                                                 else
  121.                                                     {
  122.                                                         if(AddFileTag(file_taglist,file_path,file_area,file_current,file,size))
  123.                                                             printf("~s\nAdded `%s' to file tag list.\n",name);
  124.                                                         else
  125.                                                             printf("~s\nUnable to add `%s' to file tag list.\n",name);
  126.                                                     }
  127.                                             }
  128.                                         else
  129.                                             printf("~s\nUnable to get current file.\n");
  130.                                         CloseFileGroup(group);
  131.                                     }
  132.                             }
  133.                     }
  134.                 else
  135.                     printf("~s\nCurrent file does not exist.\n");
  136.             }
  137.         else
  138.             printf("~s\nPlease enter a file area first.\n");
  139.     }
  140.